/*package com.jisheng.xb.web;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jisheng.xb.common.Constant.TransmitField;
import com.jisheng.xb.common.MD5Encrypt;
import com.jisheng.xb.core.exception.BusinessException;
import com.jisheng.xb.dao.PersonMapper;
import com.jisheng.xb.entity.Person;
import com.jisheng.xb.entity.Profile;
import com.jisheng.xb.entity.User;
import com.jisheng.xb.entity.enums.ProfileType;
import com.jisheng.xb.service.UserService;

@Controller
@RequestMapping("/login")
public class LoginController {
	final static Logger log = LoggerFactory.getLogger(LoginController.class);
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private PersonMapper personMapper;
	
	
	@RequestMapping(value = {"login"}, method = { RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
    public Model login(Model model,HttpSession session,
			@RequestParam(required = true) String userName,
			@RequestParam(required = true) String password) throws BusinessException{
		User user = userService.findPcUserByName(userName);
		
		if(user == null){
			model.addAttribute(TransmitField.Status, 0);
			model.addAttribute(TransmitField.Msg, "用户不存在");
			return model;
		}
		if(!MD5Encrypt.encode(password).equals(user.getPassword())){
			model.addAttribute(TransmitField.Status, 0);
			model.addAttribute(TransmitField.Msg, "密码错误");
			return model;
		}
		Person person = this.personMapper.selectByPrimaryKey(user.getPersonId());
		Profile profile = new Profile(ProfileType.Buyer,0,person.getName());
		profile.setUser(user);
		session.removeAttribute("profile");
		session.setAttribute("profile", profile);
		return model;
    }
	

	@RequestMapping(value = {"logout"}, method = { RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
    public void logout(HttpSession session){
		session.removeAttribute("profile");
	}
}
*/